using System.Collections.Generic;
using Lync.Widget.Library.InstantMessaging;

namespace Lync.Widget.Library.ServiceHelpers.ServiceHelpers
{
	public static class ServiceCallResponseFactory
	{
        public static ServiceCallResponse CreateSuccesfulGroupResponse(List<GroupMessage> instantMessages = null)
        {
            if (instantMessages != null)
            {
                return new GroupMessageListServiceCallResponse()
                {
                    ErrorCode = ErrorCode.NoError,
                    HasError = false,
                    ErrorMessage = "",
                    Messages = instantMessages,
                };
            }
            return new ServiceCallResponse
            {
                ErrorCode = ErrorCode.NoError,
                HasError = false,
                ErrorMessage = "",
            };
        }


		public static ServiceCallResponse CreateSuccesfulResponse(List<Message> instantMessages = null)
		{
			if (instantMessages != null)
			{
				return new MessageListServiceCallResponse()
				{
					ErrorCode = ErrorCode.NoError,
					HasError = false,
					ErrorMessage = "",
					Messages = instantMessages,
				};
			}
			return new ServiceCallResponse
			       	{
			       		ErrorCode = ErrorCode.NoError,
						HasError = false,
						ErrorMessage = "",
			       	};
		}

		public static ServiceCallResponse CreateFatalErrorResponse(string message)
		{
			return new ServiceCallResponse
			{
				ErrorCode = ErrorCode.SessionError,
				HasError = true,
				ErrorMessage = message
			};
		}

		public static ServiceCallResponse CreateCallErrorResponse(string message)
		{
			return new ServiceCallResponse
			{
				ErrorCode = ErrorCode.SingleCallError,
				HasError = true,
				ErrorMessage = message
			};
		}
	}
}